const Koa = require('koa');
const cors = require('koa2-cors');
const Router = require('koa-router');
const { CORS_CONFIG } = require('./config/cors')

const app = new Koa();

app.use(cors(CORS_CONFIG));

const indexRouter = new Router();
const customerRouter = new Router();


indexRouter.post('/', (ctx, next) => {
    ctx.body = { 'data': "后端成功处理当前Input，请继续发送请求" }
})

indexRouter.post('/page', (ctx, next) => {
    ctx.body = { 'data': "后端成功处理当前Page，请继续发送请求" }
})

// customerRouter.post('/customer', (ctx, next) => {

//     ctx.body = '后端成功处理前端请求，请继续发送请求'
// })
app.use(indexRouter.routes())
app.use(customerRouter.routes())

app.listen(8001, () => {
    console.log('server is running on http://localhost:8001')
})